/* 
 * File:   bdOper.h
 * Author: f10-kafedra
 *
 * Created on 16 Октябрь 2011 г., 11:43
 */

#ifndef BDOPER_H
#define	BDOPER_H

//#include <QtSql/QSqlDatabase>
//#include <QtSql/QSqlError>
//#include <QtSql/QSqlQuery>
#include <QStringList>
#include <stdlib.h>
#include <boost/format.hpp>
#include <QVariant>
#include <QTextCodec>
#include <iostream>
//#include <QMessageBox>
#include "../psql/9.0/include/libpq-fe.h"

using namespace std;
using boost::format;

//#define HOSTBD "127.0.0.1"
#define HOSTBD "192.168.9.254"
#define DBNAME "OurIP"
#define DBLOGIN "apm"
#define DBPASS "apm"

class bdOper {
public:
    bdOper();
    ~bdOper();

    QStringList getFilialsID();
    QStringList getFilialNames(QStringList);
    void saveAccount(QString login, QString pass, QString ip);
    QStringList checkAccountAvailable(QString ip);
    
//    QStringList getFilialsID();
//    QStringList getFilialNames(QStringList);
//    void saveAccount(QString login, QString pass, QString ip);
//    QStringList checkAccountAvailable(QString ip);
    
    //QSqlDatabase db;
    PGconn* db;
    QString myIp;
    
    
    
private:
    bool connectToBD();
    void disconnect();
    void queryError(PGresult* result);
    void getResult(PGresult** result, unsigned short int items, QStringList* container);
/*    bool connectToBD();
    void disconnect();
    void queryError(QSqlQuery query); */
    

};

#endif	/* BDOPER_H */

